<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">

    <changeSet id="001" author="alexander (bigtows) chapchuk">
        <createTable tableName="hours_per_month">
            <column name="month_date" type="date">
                <constraints primaryKey="true"/>
            </column>
            <column name="hours" type="double">
                <constraints nullable="false"/>
            </column>
        </createTable>
        <createTable tableName="workload">
            <column name="year" type="int">
                <constraints primaryKey="true"/>
            </column>
            <column name="week" type="int">
                <constraints primaryKey="true"/>
            </column>
            <column name="modality" type="varchar(15)">
                <constraints primaryKey="true"/>
            </column>
            <column name="type_modality" type="varchar(15)">
                <constraints primaryKey="true"/>
            </column>
            <column name="manual_value" type="bigint"/>
            <column name="generated_value" type="bigint"/>
        </createTable>
    </changeSet>
    <changeSet id="002" author="alexander (bigtows) chapchuk">
        <loadData tableName="workload" file="db/data/densitometer.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/flg.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/kt.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/kt_u.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/kt_u2.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/mmg.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/mrt.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/mrt_u.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/mrt_u2.csv" separator=";"/>
        <loadData tableName="workload" file="db/data/rg.csv" separator=";"/>
    </changeSet>
    <changeSet id="003" author="alexander (bigtows) chapchuk">
        <createTable tableName="week_number">
            <column name="start_date" type="date">
                <constraints primaryKey="true"/>
            </column>
            <column name="end_date" type="date">
                <constraints primaryKey="true"/>
            </column>
            <column name="week_number" type="int">
                <constraints nullable="false"/>
            </column>
        </createTable>
        <loadData tableName="week_number" file="db/data/calendar/calendar_week-2022-2024.csv" separator=";"/>
    </changeSet>
    <changeSet id="004" author="alexander (bigtows) chapchuk">
        <loadData tableName="week_number" file="db/data/calendar/calendar_week-2025-2027.csv" separator=";"/>
    </changeSet>

    <changeSet id="005" author="alexander (bigtows) chapchuk">
        <sql>
            DELETE
            FROM workload
            WHERE generated_value &lt; 0;
        </sql>
    </changeSet>
</databaseChangeLog>
